<div class="service_admin_section">
    <style>
        .service_admin_section .form-group {
            margin-bottom:10px;
        }
        .service_admin_section .str_box {
            display: block;
            padding-top: 6px;
            padding-bottom: 0;
        }
    </style>
    <form id="migration" action="{:url('service',['action'=>'handle'])}" method="post" class="form-horizontal">
        <input type="hidden" name="id" value="{$data.id}">
        
        <div>
        {switch name="data.status"}
            {case value="-1"}
            <input type="hidden" name="status" value="1">
            <div class="form-group">
                <label for="exampleInputAccount4" class="col-sm-2">类型</label>
                <div class="col-md-10 col-sm-10">
                    <span class="str_box">{$data.type_str}</span>
                </div>
            </div>

            <div class="form-group">
                <label for="exampleInputAccount4" class="col-sm-2">申请理由</label>
                <div class="col-md-10 col-sm-10">
                    <span class="str_box">{$data.description}</span>
                </div>
            </div>

            <div class="form-group">
                <label for="exampleInputAccount4" class="col-sm-2">图片</label>
                <div class="col-md-10 col-sm-10">
                    {volist name="data.images_small" id="images"}
                        <a href="{$data.images_big[$key]}" target="_blank"><img src="{$images}"/></a>
                    {/volist}
                </div>
            </div>

            <div class="form-group">
                <label for="exampleInputAccount4" class="col-sm-2">是否同意</label>
                <div class="col-md-10 col-sm-10">
                    <label class="radio-inline">
                      <input data-role="agree" type="radio" name="status" value="1" checked> 同意
                    </label>
                    <label class="radio-inline">
                      <input data-role="refuse" type="radio" name="status" value="-1"> 拒绝
                    </label>
                </div>
            </div>

            <div class="form-group hidden reason">
                <label for="exampleInputAccount4" class="col-sm-2">拒绝理由</label>
                <div class="col-md-10 col-sm-10">
                    <textarea class="form-control" name="reason" rows="3" placeholder="拒绝理由"></textarea>
                </div>
            </div>

            <div class="form-group">
                <label for="exampleInputAccount4" class="col-sm-2"></label>
                <div class="col-md-10 col-sm-10">
                    <a class="btn btn-success" data-role="submit">确认提交</a>
                    <a onclick="$('.close').click();" class="btn">返回</a>
                </div>
            </div>
            {/case}

            {case value="0"}
            <input type="hidden" name="status" value="1">
            <div class="form-group">
                <label for="exampleInputAccount4" class="col-sm-2">类型</label>
                <div class="col-md-10 col-sm-10">
                    <span class="str_box">{$data.type_str}</span>
                </div>
            </div>

            <div class="form-group">
                <label for="exampleInputAccount4" class="col-sm-2">申请理由</label>
                <div class="col-md-10 col-sm-10">
                    <span class="str_box">{$data.description}</span>
                </div>
            </div>

            <div class="form-group">
                <label for="exampleInputAccount4" class="col-sm-2">图片</label>
                <div class="col-md-10 col-sm-10">
                    {volist name="data.images_small" id="images"}
                        <a href="{$data.images_big[$key]}" target="_blank"><img src="{$images}"/></a>
                    {/volist}
                </div>
            </div>

            <div class="form-group">
                <label for="exampleInputAccount4" class="col-sm-2">是否同意</label>
                <div class="col-md-10 col-sm-10">
                    <label class="radio-inline">
                      <input data-role="agree" type="radio" name="status" value="1" checked> 同意
                    </label>
                    <label class="radio-inline">
                      <input data-role="refuse" type="radio" name="status" value="-1"> 拒绝
                    </label>
                </div>
            </div>

            <div class="form-group hidden reason">
                <label for="exampleInputAccount4" class="col-sm-2">拒绝理由</label>
                <div class="col-md-10 col-sm-10">
                    <textarea class="form-control" name="reason" rows="3" placeholder="拒绝理由"></textarea>
                </div>
            </div>

            <div class="form-group">
                <label for="exampleInputAccount4" class="col-sm-2"></label>
                <div class="col-md-10 col-sm-10">
                    <a class="btn btn-success" data-role="submit">确认提交</a>
                    <a onclick="$('.close').click();" class="btn">返回</a>
                </div>
            </div>
            {/case}

            {case value="1"}
                <input type="hidden" name="status" value="2">
                <div style="width: 100%;text-align: center;">
                    <h4>等待买家退货，无需操作</h4>
                    <a onclick="$('.close').click();" class="btn btn-default">返回</a>
                </div>
            {/case}

            {case value="2"}
                <input type="hidden" name="status" value="3">
                <div style="width: 100%;text-align: center;">
                    <h4>确认已收到用户退回的商品</h4>
                    <a class="btn btn-primary" data-role="submit">确认</a>
                    <a onclick="$('.close').click();" class="btn btn-default">返回</a>
                </div>
            {/case}

            {case value="3"}
                <input type="hidden" name="status" value="4">
                <div style="width: 100%;text-align: center;">
                    {eq name="data.type" value="exchange"}
                        <h4>换货处理</h4>
                        {notempty name="delivery"}
                        <!--发货&&改物流-->
                        <div class="form-group">
                            <label class="col-sm-2">快递公司：</label>
                            <div class="col-md-8">
                                <select class="form-control" name="ShipperValue">
                                    {foreach name="delivery" item="vo" }
                                    <option value ="{$vo},{$key}" >{$vo}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2">快递单号：</label>
                            <div class="col-md-8">
                                <input type="text" class="form-control" name="LogisticCode">
                            </div>
                        </div>
                    {else /}
                        <div class="text-center">未配置物流插件或不支持的插件</div>
                        {/notempty}
                    {/eq}
                    {eq name="data.type" value="return"}
                        <h4>退货处理</h4>
                    {/eq}
                    
                    <a class="btn btn-primary" data-role="submit">确认</a>
                    <a onclick="$('.close').click();" class="btn btn-default">返回</a>
                </div>
            {/case}

            {case value="4"}
                {eq name="data.type" value="exchange"}
                    <h4>商品已发出，等待买家确认</h4>
                {/eq}
                {eq name="data.type" value="return"}
                    <h4>退货退款</h4>
                {/eq}
            {/case}

        {/switch}
        </div>
    </form>
</div>
<script>
    $(function(){
        $('[name="status"]').click(function(){
            console.log($(this).val());
            if($(this).val() == -1){
                $('.reason').removeClass('hidden');
            }else{
                $('.reason').addClass('hidden');
            }
        })

        $('[data-role="submit"]').click(function(e){
            e.preventDefault();
            query=$('#migration').serialize();
            var url=$('#migration').attr('action');
            $.post(url,query,function(msg){
                if(msg.code){
                    toast.success(msg.msg);
                    setTimeout(function(){
                        window.location.href=msg.url;
                    },1500);
                }else{
                    handleAjax(msg);
                }
            },'json');
        });
    });
</script>